﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mamnontuoitho7.AppCode;
using System.Data;

namespace mamnontuoitho7.backend
{
    public partial class ContactList : System.Web.UI.Page
    {
        Contact _contact = new Contact();
        protected General _general = new General();

        protected DataTable _dt;
        protected void Page_Load(object sender, EventArgs e)
        {
            //Check Role Admin
            if (Session["memberID"].ToString() != "" && (ConstantClass.permissionInfo).IndexOf(Session["role"].ToString() + ",") != -1)
            {
                try
                {
                    if (Request.Form["hidContactIDDelete"] != null)
                    {
                        string _contactID = Request.Form["hidContactIDDelete"].ToString();
                        _contact.ContactDelete(_contactID);
                    }
                    if (Request.Form["hidContactID"] != null)
                    {
                        string _contactID = Request.Form["hidContactID"].ToString();
                        _contact.ChangeContactStatus(_contactID);
                    }

                    _dt = _contact.GetContact();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Response.Redirect(ConstantClass._errorAdminPage);
                }
            }
            else
            {
                Response.Redirect(ConstantClass._errorLoginPage);
            }
        }
    }
}